<template>
	<view>
		<uni-datetime-picker v-model="queryParams.betweenTime" start-placeholder="start" end-placeholder="end"
			:clear-icon="false" type="daterange" rangeSeparator="--" @change="change" />
		<view v-for="(item, index) in noticeList" :key="index">
			<ListItem :title="item.title" >
				<template #date>
					<text>{{item.update_time}}</text>
				</template>
				<template #connect>
					<text>{{item.content}}</text>
				</template>
			</ListItem>
		</view>
		<empty v-show="noticeList.length==0"></empty>
	</view>
</template>

<script>
	import ListItem from '@/components/basicListItem/ListItem/ListItem.vue'
	import common from "@/api/common.js"
	export default {
		components:{
			ListItem,
		},
		data() {
			return {
				isShow:false,
				queryParams: {
					page: '1',
					betweenTime: []
				},
				noticeList:[],
				lastPage: ''
			}
		},
		// 底部上拉刷新
		onReachBottom(){
			if(this.lastPage > 1 && this.queryParams.page <= this.lastPage){    
				//判断是否还有数据需要加载
					uni.showLoading({
						title: 'Loading'
					});
					setTimeout(function () {
						uni.hideLoading();
					}, 2000);
					this.queryParams.page ++
					this.getList()
				}else{
					uni.showToast({
						title: 'nomoreText',
						icon:'none'
					});
				}
		},
		onLoad() {
			this.getList()
		},
		methods: {
		  getList() {
		    common.getNoticeList(this.queryParams).then((res) => {
		      if (this.queryParams.page === 1) {
		        this.noticeList = res.data.list.data;
		      } else {
		        this.noticeList = this.noticeList.concat(res.data.list.data);
		      }
		      this.lastPage = res.data.list.last_page;
		    });
		  },
		  // 搜索
		  change(e) {
			  uni.showLoading({
			  	title: 'Loading'
			  });
			  this.queryParams.page = 1; // 重置页码为1
			  this.noticeList = []; // 清空数组
			  this.debounce(() => {
			  	this.getList()
			  }, 500);
		  }
		}
	}
</script>

<style scoped>
page {
		background-color: #F5F5F5;
	}
	::v-deep .uni-date-x--border {
		border: none !important;
	}
	
	::v-deep .uni-date-x {
		border: none !important;
		background: #FFFFFF;
		box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(174, 174, 174, 0.16);
		margin-bottom: 25rpx;
		border-radius: 100rpx;
		color: #1C2026;
		text-align: center;
		line-height: 66rpx;
	}
</style>